from datetime import *


class CacheRankUtils:

    @staticmethod
    def iosbussines(path):
        if path == "~/Library/FileCaches/video_offlinecache":
            return "视频"
        if path == "~/Library/FileCaches/WB_UPLOADFILES":
            return "视频"
        if path == "~/Library/FileCaches/WBVideo_Production":
            return "视频"
        if path == "~/Library/Caches/mediaUploadCache":
            return "视频"
        if path == "~/tmp/com.alamofire.uploads":
            return "架构组"
        if path == "~/Librarysssss/FileCaches/WBStory_Production":
            return "视频"
        if path == "~/Documents-weibodb.dat":
            return "架构组"
        if path == "~/Documents-message.db":
            return "消息箱"
        if path == "~/Documents/analysis_log":
            return "架构组"
        if path == "~/tmp/com.apple.dyld":
            return "架构组"
        if path == "~/Library/FileCaches/image_usereditor_caches":
            return "图片(生产)"
        if path == "~/Library/FileCaches/Filters_Stickers":
            return "图片(生产)"
        if path == "~/Library/FileCaches/WBUserPickerCache":
            return "图片(生产)"
        if path == "~/Library/FileCaches/Upload":
            return "消息箱"
        if path == "~/Library/Attachments":
            return "消息箱"
        if path == "~/Library/Caches/wgapp":
            return "小程序"
        if path == "~/Library/WBMP":
            return "小程序"
        if path == "~/tmp/WBAudioCachTmpPath":
            return "pagecard"
        if path == "~/Documents/FileCaches/WBChannelDataProviderCacheNewNameSpace":
            return "pagecard"
        return "-"

    @staticmethod
    def iosignorpath(key):
        if key == "~/Documents":
            return True
        if key == "~/Library":
            return True
        if key == "~/Library/FileCaches":
            return True
        if key == "~/Documents/FileCaches":
            return True
        if key == "~/Library/Caches":
            return True
        if "-FILES" in key:
            return True
        return False

    @staticmethod
    def androidbussines(path):
        if path == "weibo/files/sina/weibo/storage/appmarket":
            return "商业化"
        if path == "data_cache/app_bundles":
            return "小程序"
        if path == "weibo/files/sina/weibo/storage/photoalbum_edit":
            return "图片发布"
        if path == "weibo/files/sina/weibo/storage/video_download":
            return "视频"
        if path == "weibo/files/sina/weibo/storage/story":
            return "视频"
        if path == "data_cache/databases":
            return "数据库"
        if path == "weibo/files/sina/weibo/storage/photoalbum_tool":
            return "图片发布"
        if path == "weibo/files/sina/weibo/storage/wbox_app_library":
            return "小程序"
        if path == "data_cache/files/.wbdbbak":
            return "数据库"
        if path == "weibo/files/sina/weibo/storage/story_wuta":
            return "视频"
        if path == "data_cache/draft_db_back":
            return "草稿箱"
        if path == "data_cache/files/yttrium":
            return "浏览器"
        if path == "weibo/files/sina/weibo/storage/composer_temp":
            return "发布器"
        if path == "data_cache/cache/image_manager_disk_cache":
            return "图片消费"
        if path == "weibo/files/sina/weibo/storage/sdk_aqts":
            return "架构组"
        if path == "data_cache/cache/webview_com.sina.weibo":
            return "浏览器"
        if path == "data_cache/app_dex":
            return "架构组"
        if path == "weibo/files/sina/weibo/storage/photoalbum_emotion":
            return "发布器"
        if path == "weibo/files/sina/weibo/storage/pagecard_no_auto_clear":
            return "pagecard"
        if path == "data_cache/app_webview_com.sina.weibo":
            return "浏览器"
        if path == "weibo/files/sina/weibo/storage/biz_keep":
            return "商业化"
        if path == "data_cache/app_wbplugin":
            return "架构组"
        return "-"

    @staticmethod
    def get_lastday_range(time_format_type=1, days=1):
        now_time = datetime.now()
        if time_format_type == 1:
            lastday = (now_time + timedelta(days=-days)).strftime('%Y-%m-%d-00-00')
            today = now_time.strftime('%Y-%m-%d-00-00')
            timestamp = '%s~%s' % (lastday, today)
            return timestamp
        elif time_format_type == 2:
            lastday = (now_time + timedelta(days=-days)).strftime('%Y%m%d')
            return lastday
